package com.aaa.service.impl;
import com.aaa.dao.T_CommentSettingsDao;
import com.aaa.service.T_CommentSettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: TT
 * @Date: 2019/3/19 15:40
 * @Version 1.0
 */
@Service
public class T_CommentSettingsServiceImpl implements T_CommentSettingsService {

    @Autowired
    T_CommentSettingsDao dao;
    @Override
    public List<Map> list(Map map) {
        return dao.list(map);
    }

    @Override
    public Integer count(Map map) {
        return dao.count(map);
    }

    @Override
    public Integer insert(Map map) {
        return dao.insert(map);
    }
    @Override
    public Integer update(Map map) {
        return dao.update(map);
    }

    @Override
    public Integer del(Integer id) {
        System.out.println( dao.updxid(id)+"111111111111111111111111111111");
            dao.updxid(id);
        return dao.del(id);
    }

    @Override
    public List<Map> person(Map map) {
        return dao.person(map);
    }

    @Override
    //修改评议人员选中状态
    public Integer upd(Integer id) {
        return dao.upd(id);
    }
    //添加评议人员
    @Override
    public List<Map> insertxid() {
        return dao.insertxid();
    }
    //修改移除评议人员选中状态
    @Override
    public Integer updxid(Integer id) {
        return dao.updxid(id);
    }

    @Override
    public String supdxid() {

        List<Map> list=dao.supdxid();
        String pstate="";
        for (int i = 0; i <list.size(); i++) {
            Map map=list.get(i);
            String str=map.get("id").toString();
            if (i==list.size()-1){
                pstate+=str;
                break;
            }
            pstate+=str+",";
        }
         return pstate;
    }

    @Override
    public Integer xids() {
        return dao.xids();
    }

    @Override
    public Object selectId(Map map) {
        List list=new ArrayList();
        Map map1=new HashMap();
        String pstate1=(String) map.get("pstate");
        String[] ns=pstate1.split(",");
        System.out.println();
        Map map2=new  HashMap();
        int[] arr=new int[pstate1.length()];
        for (int i = 0; i <ns.length ; i++) {
            arr[i]=Integer.parseInt(ns[i]);
          //  map1.put("pstate",Integer.parseInt(ns[i]));
           list.add(dao.selectId(arr[i]));
        }
        map2.put("datass",list);

        return  map2;
    }

    @Override
    public Integer ups(Integer id) {
        return dao.ups(id);
    }
}
